<?php

/* @var $this yii\web\View */
use yii\bootstrap\Alert;
use yii\helpers\Url;

$this->title = date('Y',time()).$model->city_name."平均工资水平/怎么样--大牛数据平台";
?>



<div class="body">
    <div id="socialContainer">

        <div class="container">
            <div class="narrow">
                <div><div class="job-list-message">
                        <h2 class="pull-left"><?php echo date('Y',time()).$model->city_name; ?>平均工资水平</h2>
                        <div class="pull-right">
                            <span class="blue search-key pull-left"></span>
                            <div class="pull-right">
                                <a href="#talk" style="text-decoration:none;"><span class="red">来吧！我想吐槽└(^o^)┘</span></a>
                            </div>
                        </div>
                    </div>
                    <div class="job-list">
                        <div class="list-header">

                        </div>
                        <div class="list-body" id="avgdesc" style="height:400px">

                        </div>
                        <div class="list-header">

                        </div>
                        <div class="list-body" id="total_num" style="height:400px">

                        </div>
                    </div>
                </div>
            </div>
            <div class="narrow">
                <div><div class="job-list-message">
                        <h2 class="pull-left"><?php echo date('Y',time()).$model->city_name; ?>每个职位工资水平情况</h2>
                        <div class="pull-right">
                            <span class="blue search-key pull-left"></span>
                        </div>
                    </div>
                    <div class="job-list">
                        <div class="list-header">
                            <div class="list-row">
                                <div class="column1" style="width: 20%">
                                    城市
                                </div>
                                <div class="column1" style="width: 16%">
                                    平均工资
                                </div>
                                <div class="column1" style="width: 16%">
                                    总招聘数
                                </div>
                                <div class="column1" style="width: 16%">
                                    面谈数
                                </div>
                                <div class="column1" style="width: 16%">
                                    20K以上
                                </div>
                                <div class="column1" style="width: 16%">
                                    更新时间
                                </div>
                            </div>
                        </div>
                        <div class="list-body">
                            <?php
                            foreach($citybyJobsData as $jobData){

                                ?>
                                <div class="list-row">
                                    <div class="column1" style="width: 20%">
                                        <a href="<?php echo Url::to(['base/index','cityid'=>$model->id,'jobid'=>$jobData['job_id']]); ?>" target="_blank"><?php echo $jobData['job_name'] ?></a>
                                    </div>
                                    <div class="column1" style="width: 16%">
                                        <?php echo $jobData['avg'] ?>
                                    </div>
                                    <div class="column1" style="width: 16%">
                                        <?php echo $jobData['total'] ?>
                                    </div>
                                    <div class="column1" style="width: 16%">
                                        <?php echo $jobData['talk'] ?>
                                    </div>
                                    <div class="column1" style="width: 16%">
                                        <?php echo $jobData['20k'] ?>
                                    </div>
                                    <div class="column1" style="width: 16%">
                                        <?php echo $jobData['date_line'] ?>
                                    </div>
                                </div>
                            <?php } ?>
                        </div>
                    </div>
                    <div class="job-list">
                        <div class="list-header">
                            <a name="talk"></a>
                            <h2>吐吐槽，喷喷沫！</h2>
                        </div>
                        <div class="list-body" style="padding:60px;padding-top: 30px;">
                            <!-- UY BEGIN -->
                            <div id="uyan_frame"></div>
                            <script type="text/javascript" src="http://v2.uyan.cc/code/uyan.js?uid=2070675"></script>
                            <!-- UY END -->
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>

<script type="text/javascript">
    // 路径配置
    require.config({
        paths: {
            echarts: 'http://echarts.baidu.com/build/dist'
        }
    });

    // 使用
    require(
        [
            'echarts',
            'echarts/theme/macarons',
            'echarts/chart/line' // 使用柱状图就加载bar模块，按需加载
        ],
        function (ec,theme) {
            //通过Ajax获取数据
            $.ajax({
                type: "post",
                async: false, //同步执行
                url: "index.php?r=city%2Favgchangeajax&id=<?php echo $model->id ?>",
                dataType: "json",
                success:function (result) {
                    if (result) {
                        //将返回的category和series对象赋值给options对象内的category和series
                        //因为xAxis是一个数组 这里需要是xAxis[i]的形式
                        date_line = [];
                        avg =[];
                        max_avg = [];
                        min_avg = [];
                        for(var row in result){
                            date_line[row] = result[row].date_line;
                            avg[row] = result[row].avg;
                            max_avg[row] = result[row].max_avg;
                            min_avg[row] = result[row].min_avg;
                        }
                    }
                },
                error: function (errorMsg) {
                    alert("不好意思，大爷，图表请求数据失败啦!");
                }
            });

            // 基于准备好的dom，初始化echarts图表
            var myChart = ec.init(document.getElementById('avgdesc'),theme);

            var option = {
                title : {
                    text: '平均工资过去一周变化',
                    subtext: ''
                },
                tooltip : {
                    trigger: 'axis'
                },
                legend: {
                    data:['平均工资','最高平均工资','最低平均工资']
                },
                toolbox: {
                    show : true,
                    feature : {
                        saveAsImage : {show: true}
                    }
                },
                calculable : true,
                xAxis : [
                    {
                        type : 'category',
                        boundaryGap : false,
                        data : date_line
                    }
                ],
                yAxis : [
                    {
                        type : 'value',
                        axisLabel : {
                            formatter: '{value}'
                        }
                    }
                ],
                series : [
                    {
                        name:'平均工资',
                        type:'line',
                        data:avg,
                        markPoint : {
                            data : [
                                {type : 'max', name: '最大值'},
                                {type : 'min', name: '最小值'}
                            ]
                        }
                    },
                    {
                        name:'最高平均工资',
                        type:'line',
                        data:max_avg
                    },
                    {
                        name:'最低平均工资',
                        type:'line',
                        data:min_avg
                    }
                ]
            };




            // 为echarts对象加载数据
            myChart.setOption(option);
        }
    );

</script>
<script type="text/javascript">
    // 路径配置
    require.config({
        paths: {
            echarts: 'http://echarts.baidu.com/build/dist'
        }
    });

    // 使用
    require(
        [
            'echarts',
            'echarts/theme/macarons',
            'echarts/chart/line' // 使用柱状图就加载bar模块，按需加载
        ],
        function (ec,theme) {
            //通过Ajax获取数据
            $.ajax({
                type: "post",
                async: false, //同步执行
                url: "index.php?r=city%2Favgchangeajax&id=<?php echo $model->id ?>",
                dataType: "json",
                success:function (result) {
                    if (result) {
                        //将返回的category和series对象赋值给options对象内的category和series
                        //因为xAxis是一个数组 这里需要是xAxis[i]的形式
                        date_line = [];
                        total_num = [];
                        for(var row in result){
                            date_line[row] = result[row].date_line;
                            total_num[row]=result[row].total_num;
                        }
                    }
                },
                error: function (errorMsg) {
                    alert("不好意思，大爷，图表请求数据失败啦!");
                }
            });

            // 基于准备好的dom，初始化echarts图表
            var myChart = ec.init(document.getElementById('total_num'),theme);

            var option = {
                title : {
                    text: '招聘总量一周变化情况',
                    subtext: ''
                },
                tooltip : {
                    trigger: 'axis'
                },
                legend: {
                    data:['招聘总量']
                },
                toolbox: {
                    show : true,
                    feature : {
                        mark : {show: true},
                        dataView : {show: true, readOnly: false},
                        magicType : {show: true, type: ['line', 'bar', 'stack', 'tiled']},
                        restore : {show: true},
                        saveAsImage : {show: true}
                    }
                },
                calculable : true,
                xAxis : [
                    {
                        type : 'category',
                        boundaryGap : false,
                        data : date_line
                    }
                ],
                yAxis : [
                    {
                        type : 'value'
                    }
                ],
                series : [
                    {
                        name:'招聘量',
                        type:'line',
                        smooth:true,
                        itemStyle: {normal: {areaStyle: {type: 'default'}}},
                        data:total_num
                    }
                ]
            };





            // 为echarts对象加载数据
            myChart.setOption(option);
        }
    );

</script>


